package com.three.productList.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.three.core.entity.Product;
import com.three.core.entity.ProductReview;
import com.three.core.vo.R;
import com.three.productList.service.ProductReviewService;
import com.three.productList.vo.EvaluateVo;
import com.three.productList.vo.ProductRatVo;
import com.three.productList.vo.SearchFormReview;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：li
 * @date ：Created in 2025/3/13 013 16:14
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/product/review")
public class ProductReviewController {
    @Autowired
    private ProductReviewService productReviewService;
    //查询评论,展示表格数据，pc端
    @PostMapping("/select")
    public R<IPage<ProductReview>> selectProductReview(@RequestBody SearchFormReview searchForm) {
        return productReviewService.selectProductReview(searchForm);
    }

    //通过productId查询评分
    @PostMapping("/selectCommentsVoByProductId")
    public R<List<EvaluateVo>> selectCommentsVoByProductId(Integer productId){
        return productReviewService.selectCommentsVoByProductId(productId);
    }
    //查询商品评价，手机端展示数据
    @PostMapping("/selectCommentsByProductId")
    public R<List<ProductReview>> selectCommentsByProductId(Integer productId){
        return productReviewService.selectCommentsByProductId(productId);
    }
    //查询商品评价的数量和好评率
    @PostMapping("/selectContentByProductId")
    public R<ProductRatVo> selectContentByProductId(Integer productId){
        return productReviewService.selectContentByProductId(productId);
    }

}
